{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Asia Bayesian Network."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "authors:<br>\n",
    "Jacob Schreiber [<a href=\"mailto:jmschreiber91@gmail.com\">jmschreiber91@gmail.com</a>]<br>\n",
    "Nicholas Farn [<a href=\"mailto:nicholasfarn@gmail.com\">nicholasfarn@gmail.com</a>]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This example shows how to create an Asia Bayesian Network. A description of the network can be found <a href=\"http://www.norsys.com/tutorials/netica/secA/tut_A1.htm\">here</a>."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Populating the interactive namespace from numpy and matplotlib\n"
     ]
    }
   ],
   "source": [
    "%pylab inline\n",
    "from pomegranate import *"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's create the distributions starting with Asia and the conditional probability for tuberculosis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "asia = DiscreteDistribution( { 'True' : 0.5, 'False' : 0.5 } )\n",
    "\n",
    "tuberculosis = ConditionalProbabilityTable(\n",
    "    [[ 'True', 'True', 0.2 ],\n",
    "     [ 'True', 'False', 0.8 ],\n",
    "     [ 'False', 'True', 0.01 ],\n",
    "     [ 'False', 'False', 0.99 ]], [asia])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "Then the distribution for smoking along with the conditional probability of lung cancer and bronchitis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "smoking = DiscreteDistribution( { 'True' : 0.5, 'False' : 0.5 } )\n",
    "\n",
    "lung = ConditionalProbabilityTable(\n",
    "    [[ 'True', 'True', 0.75 ],\n",
    "     [ 'True', 'False', 0.25 ],\n",
    "     [ 'False', 'True', 0.02 ],\n",
    "     [ 'False', 'False', 0.98 ]], [smoking] )\n",
    "\n",
    "bronchitis = ConditionalProbabilityTable(\n",
    "    [[ 'True', 'True', 0.92 ],\n",
    "     [ 'True', 'False', 0.08 ],\n",
    "     [ 'False', 'True', 0.03 ],\n",
    "     [ 'False', 'False', 0.97 ]], [smoking] )\n",
    "\n",
    "tuberculosis_or_cancer = ConditionalProbabilityTable(\n",
    "    [[ 'True', 'True', 'True', 1.0 ],\n",
    "     [ 'True', 'True', 'False', 0.0 ],\n",
    "     [ 'True', 'False', 'True', 1.0 ],\n",
    "     [ 'True', 'False', 'False', 0.0 ],\n",
    "     [ 'False', 'True', 'True', 1.0 ],\n",
    "     [ 'False', 'True', 'False', 0.0 ],\n",
    "     [ 'False', 'False', 'True', 0.0 ],\n",
    "     [ 'False', 'False', 'False', 1.0 ]], [tuberculosis, lung] )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then the probability of an x-ray, which is dependent on whether one has tuberculosis or cancer."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "xray = ConditionalProbabilityTable(\n",
    "    [[ 'True', 'True', 0.885 ],\n",
    "     [ 'True', 'False', 0.115 ],\n",
    "     [ 'False', 'True', 0.04 ],\n",
    "     [ 'False', 'False', 0.96 ]], [tuberculosis_or_cancer] )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finally the probability of dyspnea, which is dependent on whether one has bronchitis and tuberculosis or cancer."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "dyspnea = ConditionalProbabilityTable(\n",
    "    [[ 'True', 'True', 'True', 0.96 ],\n",
    "     [ 'True', 'True', 'False', 0.04 ],\n",
    "     [ 'True', 'False', 'True', 0.89 ],\n",
    "     [ 'True', 'False', 'False', 0.11 ],\n",
    "     [ 'False', 'True', 'True', 0.96 ],\n",
    "     [ 'False', 'True', 'False', 0.04 ],\n",
    "     [ 'False', 'False', 'True', 0.89 ],\n",
    "     [ 'False', 'False', 'False', 0.11 ]], [tuberculosis_or_cancer, bronchitis])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now let's create the states for our bayesian network."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "s0 = State( asia, name=\"asia\" )\n",
    "s1 = State( tuberculosis, name=\"tuberculosis\" )\n",
    "s2 = State( smoking, name=\"smoker\" )\n",
    "s3 = State( lung, name=\"cancer\" )\n",
    "s4 = State( bronchitis, name=\"bronchitis\" )\n",
    "s5 = State( tuberculosis_or_cancer, name=\"TvC\" )\n",
    "s6 = State( xray, name=\"xray\" )\n",
    "s7 = State( dyspnea, name='dyspnea' )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finally we can create our bayesian network. We do this by creating an instance of BayesianNetwork, then adding the states."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "network = BayesianNetwork( \"asia\" )\n",
    "network.add_nodes(s0, s1, s2, s3, s4, s5, s6, s7)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then we add the edges to our network."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "network.add_edge( s0, s1 )\n",
    "network.add_edge( s1, s5 )\n",
    "network.add_edge( s2, s3 )\n",
    "network.add_edge( s2, s4 )\n",
    "network.add_edge( s3, s5 )\n",
    "network.add_edge( s5, s6 )\n",
    "network.add_edge( s5, s7 )\n",
    "network.add_edge( s4, s7 )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We finish by baking our network to finalize its structure."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "network.bake()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's take a look at the resulting structure:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPEAAADnCAYAAADPRLCPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO2dd1hUR/fHvwvSwQKiEhFj7KBYEcWCoPLasAWJMRJrNDY0MVHjL3aNMfYCryWaWONLiDXFECNiiRhERQULKEgRFNClCVvY8/tjZAUFZJfdvXeX+3mefWDv3pk59+6eOzNnzpwjIiIICAjoL0ZcCyAgIFA9BCUWENBzBCUWENBzBCUWENBzBCUWENBzar3lc8F0LSDAD0QVfSD0xAICeo6gxAICes7bhtP8Ze9e4Px54Pp14N49oGlToHNnwN4eMDMDLC0BuRzIyQHS0oDHj9nfggJg0iSgTx/2qleP6yupGeTlATEx7HXzJvvOLl0CnJwAW1vAzg6oX//V92duzr4/qRTIzweystgrOxt4+hR4/hzo1w9wdgY6dGCvtm2BWvr7k1YX0Vs8tvg1J46NBQ4fBo4eZQrr7Q106sS+SHPzqtWRlQXs2sUeAJGRrJ6RI4HZs7Ure00kNxcIC2P3+scfXymcqyvg4gL07g0YG6tX94sXwLlzrx4Mt28DSUnA/Pnsd9Gjh/p185MK58T6ocSHDgHBwUByMjBuHDBqFODmVv16pVLg9Gng+HH2/9y5QNeu1a+3prN1K3DqFHtIenkxZf38c+0rVU4O8M03wN9/A4mJwODB7LcycqR229UNeqzEBw6wp3hgIODrCxhpaRq/dSvw3Xesp1i9GujYUTvtGCoKBXDyJJvm1K8PDBsG+PiwaQ0XpKWxB0loKBtmT50KtG/PjSyaoUIlBhFV9uKOmBiinj2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FlJeXR3l5edVqSy3WrydycKhOsANhPzGvyc4G+vbV/BO6uqSlsWWghQuBwYO108b06cwve8QIYPNmtaupiveWmZkZrK2tYW1trXY7KpOZySJwhoQAFy5oxrr/GoIS84GICBb7ePRo9pcPPHgAODoCy5ezYb82GTGCLbedOAFcu6bdtnQJEVNaJycWKvi1JT9NISgxXwgPZ0EBevXS7NxTHU6eBHr2BPbsAaZO1U2bTZowN0RfX+CDDzTj3sklx4+zqKHh4cCGDSxYvbaobKxdzVmAgLpwFe0yKEiIdqkupaNd/vqrNlqoUE+FoAB8RZdxp/ftA9atYz3HqlVC3OmqIJMxq3pYGOdxpwUl5jPlZYBYs0YzdZdkgAgIYB5Uc+bwOgMEpFKmJKdOMbkBlkqlRw/tZIAoj5IMEJcvsyD7rVqxB8qoUbrIACEosd5Tkovp4EE2b/byepWL6WVi8beix7mY3uDuXeCbb17lYipJeObnp5lcTFlZ7MH5++9v5mLq0YM9QHR73wQlNhhKZ0W8cYNlRXRzY1kRGzRgWfusrJgDSemsiKmpLH+QHmZFfCvPnrFYXbGxzMKdlFR+VkRzc2ZgKsmMWFFWxJQUdq6TE+tphayIAgICGkAIlCcgYKgISiwgoOe8zXubZykJBAQEXkfoiQUE9BxBiQUE9BxBiQUE9BxBiQUE9BxBiQUE9BxBiQUE9Jz/B/lYzQFWh0UjAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "network.plot()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now let's test out our network on a person who has tuberculosis, is not a smoker, and has bronchitis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "asia\t\t{\n",
      "    \"class\" :\"Distribution\",\n",
      "    \"dtype\" :\"str\",\n",
      "    \"name\" :\"DiscreteDistribution\",\n",
      "    \"parameters\" :[\n",
      "        {\n",
      "            \"True\" :0.9523809523809521,\n",
      "            \"False\" :0.04761904761904782\n",
      "        }\n",
      "    ],\n",
      "    \"frozen\" :false\n",
      "}\n",
      "tuberculosis\t\tTrue\n",
      "smoker\t\tFalse\n",
      "cancer\t\t{\n",
      "    \"class\" :\"Distribution\",\n",
      "    \"dtype\" :\"str\",\n",
      "    \"name\" :\"DiscreteDistribution\",\n",
      "    \"parameters\" :[\n",
      "        {\n",
      "            \"False\" :0.9799999999999995,\n",
      "            \"True\" :0.020000000000000438\n",
      "        }\n",
      "    ],\n",
      "    \"frozen\" :false\n",
      "}\n",
      "bronchitis\t\tTrue\n",
      "TvC\t\t{\n",
      "    \"class\" :\"Distribution\",\n",
      "    \"dtype\" :\"str\",\n",
      "    \"name\" :\"DiscreteDistribution\",\n",
      "    \"parameters\" :[\n",
      "        {\n",
      "            \"False\" :0.0,\n",
      "            \"True\" :1.0\n",
      "        }\n",
      "    ],\n",
      "    \"frozen\" :false\n",
      "}\n",
      "xray\t\t{\n",
      "    \"class\" :\"Distribution\",\n",
      "    \"dtype\" :\"str\",\n",
      "    \"name\" :\"DiscreteDistribution\",\n",
      "    \"parameters\" :[\n",
      "        {\n",
      "            \"False\" :0.11500000000000017,\n",
      "            \"True\" :0.8849999999999999\n",
      "        }\n",
      "    ],\n",
      "    \"frozen\" :false\n",
      "}\n",
      "dyspnea\t\t{\n",
      "    \"class\" :\"Distribution\",\n",
      "    \"dtype\" :\"str\",\n",
      "    \"name\" :\"DiscreteDistribution\",\n",
      "    \"parameters\" :[\n",
      "        {\n",
      "            \"False\" :0.040000000000000216,\n",
      "            \"True\" :0.9599999999999997\n",
      "        }\n",
      "    ],\n",
      "    \"frozen\" :false\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "observations = { 'tuberculosis' : 'True', 'smoker' : 'False', 'bronchitis' : 'True' }\n",
    "beliefs = map( str, network.predict_proba( observations ) )\n",
    "print(\"\\n\".join( \"{}\\t\\t{}\".format( state.name, belief ) for state, belief in zip( network.states, beliefs ) ))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
